<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Title</title>
</head>
<body>
<form name="myForm" action="https://www.baidu.com/s">
	<input autocomplete="off" name="wd" type="text">
	<button>搜索</button>
</form>
<div id="root"></div>
<script>
	const root = document.querySelector("#root");
	function fn(res) {
		if (res.q) {
			root.innerHTML = res.g.map(item => (`
				<p>${item.q}</p>
			`)).join("");
		}else root.innerHTML = null;
	}
	
	document.myForm.wd.oninput = function () {
		// https://www.baidu.com/sugrec?prod=pc&wd=三国&cb=fn
		const script = document.createElement("script");
		script.src = "https://www.baidu.com/sugrec?prod=pc&wd=" + this.value.trim() + "&cb=fn";
		document.body.appendChild(script);
	}
</script>
</body>
</html>